package org.example.spring.annoTx;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * 注解方式的事务,不需要该织入包
 */
@Component
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:applicationContext-annoTx.xml"})
public class SpringTest_annoTx {

	@Autowired
	private AccountService accountService;
	
	@Test
	public void testTransfer(){
		try {
			accountService.transfer("Jack", "Rose", 100d);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("发生异常了,请注意");
			throw new RuntimeException("注意发生异常了");
		}
		System.out.println("----转账成功!----");
	}
}
